home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / WIN_PRO / SPT110.ZIP;1 / SPTDESCR.TXT < prev   
Encoding:
Text File  |  1993-06-18  |  18.4 KB  |  439 lines

  1. ****************************************************************************
  2. ----------------------------------------------------------------------------
  3. |                         IMPORTANT - PLEASE READ                          
  4. ----------------------------------------------------------------------------
  5. |
  6. | You have a royalty-free right to use, modify, reproduce and distribute 
  7. | the software found in these sample files provided, however, that: (a)   
  8. | you agree that the MS software is PROVIDED "AS IS" WITHOUT
  9. | WARRANTY OF ANY KIND and in no event shall MS be liable for 
  10. | any damages whatsoever in connection with your use of the software; 
  11. | and (b) the utilities are redististributed solely in conjunction with and 
  12. | as part of your software application.
  13. |                                                                          
  14. | Copyright 1993 Microsoft Corporation. All Rights Reserved.               
  15. | Microsoft and MS-DOS are registered trademarks and Microsoft Access and  
  16. | Windows are trademarks of Microsoft Corporation.                         
  17. ****************************************************************************
  18.  
  19.  
  20.  
  21. Overview
  22. --------
  23.    The SQL Pass-Through Dynamic Link Library (DLL) provides SQL support
  24.    beyond that provided by Microsoft Access linked tables. While linked
  25.    tables cover a wide range of requirements for transparent access to 
  26.    remote data, including binding Microsoft Access form, report and query
  27.    objects directly to remote tables and views and performing local-remote
  28.    joins, linked tables don't support such functionality such as executing 
  29.    row returning stored procedures, remote DDL and back end specific SQL.
  30.    The MSASP110.DLL gives the Microsoft Access Basic programmer programmatic 
  31.    access to these capabilities.
  32.  
  33. Requirements
  34. -------------------------
  35.       o Microsoft Access
  36.       o Open Database Connectivity (ODBC)
  37.  
  38. Installation
  39. -------------------------
  40.       o Copy the MSASP110.DLL file into your Windows\System directory,
  41.     or into whichever directory your system looks for DLL
  42.     files.
  43.  
  44. Description of the SQL Pass-Through DLL
  45. ---------------------------------------
  46.    The SQL pass-through interface is a Dynamic Link Library (DLL) that you
  47.    can call from Access Basic. Its purpose is to allow an Access Basic
  48.    programmer to pass back end specific (possibly row-returning) SQL
  49.    strings to an SQL processing back end. In other words, the DLL is
  50.    simply a link between Microsoft Access and ODBC. ODBC is a specification 
  51.    that defines a call-level interface, or set of function calls, 
  52.    for applications. The interface enables communication between an 
  53.    application and one or more database management systems. Note that
  54.    MSASP110.DLL doesn't parse the passed string. For example, it doesn't check
  55.    to see if a called function is actually supported by the back end. The
  56.    assumption is that users of this DLL will know the type of back end they
  57.    are connected to as well the specific version of SQL that the back end
  58.    uses. The Message table (described later in this document) documents any
  59.    errors.
  60.  
  61.    MSASP110.DLL contains four functions: one establishes a connection with a
  62.    remote database; one terminates that connection; a third performs the
  63.    SQL pass-through and deals with any returned items or messages; and a
  64.    fourth returns the last error. This last function is provided in case
  65.    an error occurs before the Message table can be created. Each of these
  66.    functions is described later in this document.
  67.  
  68.    The MSASP110.DLL creates two types of tables in Microsoft Access: Message
  69.    tables and Result tables.
  70.  
  71. Message Tables
  72. --------------
  73.    In the course of establishing links and running SQL and stored
  74.    procedures, errors and application-specific messages originate from the
  75.    remote server itself, from Microsoft Access, and from ODBC.
  76.  
  77.    MSASP110.DLL inserts the text for errors and messages in a Message table. A
  78.    specific Message table is defined for each connection. Multiple
  79.    connections may share the same Message table. Depending on how you
  80.    set the AppendMsgs argument (described later in this document) when
  81.    you make an SQL pass-through call, you can either append new messages
  82.    to the end of the Message table with each call, or purge the Message
  83.    table with each call.
  84.  
  85.    You are responsible for deleting the Message tables when they are no
  86.    longer needed.
  87.  
  88. Message Table Example
  89. ---------------------
  90.    The column headers are the names of columns in the Message table.
  91.  
  92.    Indx  Type   ErrorNum  Class   SubClass  Descript
  93.    ----  -----  --------  ------  --------  ------------------------------
  94.    123     1    -1111                       Cirrus_err_Cannot_Create_Table
  95.    124     2              07      000       Dynamic SQL Error
  96.    125     3                                SomeDatabaseErrr098: Invalid
  97.                         SQL Syntax
  98.    126     4                                Stored Procedure Returned Text
  99.  
  100.  
  101.    Indx     - Counter that serves as the primary index for the table.
  102.  
  103.    Type     - Defines the source of the error which could be:
  104.  
  105.           Const JET_ERR = 1     ' Microsoft Access-specific error.
  106.           Const ODBC_ERR = 2    ' ODBC error.
  107.           Const REMOTE_ERR = 3  ' Error returned by remote database.
  108.           Const REMOTE_MSG = 4  ' Message returned by SQL stored
  109.                     ' procedure.
  110.           Const SPT_ERR = 5     ' Message generated by MSASP110 DLL.
  111.  
  112.    ErrorNum - Number of the Microsoft Access-specific error; used only
  113.           for Microsoft Access database engine errors.
  114.  
  115.    Class    - Class of the ODBC error; used only for ODBC errors.
  116.  
  117.    SubClass - Subclass of the ODBC error; used only for ODBC errors.
  118.  
  119.    Descript - Additional text for the error or text of the message
  120.           returned by the stored procedure.
  121.  
  122.    Note   When an error is a REMOTE_ERR error, the error code and 
  123.       accompanying text appears combined in the Descript field.
  124.  
  125.  
  126. Result Tables
  127. -------------
  128.    MSASP110.DLL creates a result table when the back end returns a result
  129.    set.
  130.  
  131.    If the table name doesn't already exist in the Microsoft Access
  132.    database:
  133.  
  134.       MSASP110.DLL creates a Result table in the Microsoft Access database
  135.       with a structure matching that of the returned table.
  136.  
  137.    If the table already exists in the Microsoft Access database:
  138.  
  139.       MSASP110.DLL checks to see if the structure of the table matches the
  140.       structure of the result set returned. If it matches, MSASP110.DLL
  141.       either purges it and inserts the returned result set or appends new
  142.       results to the end of the table (depending on the value of the
  143.       AppendMsgs argument at the time of the MSASP110.DLL call). If the
  144.       structure doesn't match, MSASP110.DLL returns an error and this
  145.       (and any further) result sets will be lost.
  146.  
  147.    You are responsible for deleting Result tables when they are no
  148.    longer needed.
  149.  
  150. SPT Application Programming Interface
  151. -------------------------------------
  152.    Error Codes
  153.  
  154.       Each of the MSASP110.DLL functions returns one of six error codes:
  155.  
  156.     
  157.       Const RMT_SUCCESS = 0              ' Operation succeeded with no
  158.                      ' messages or errors.
  159.       Const RMT_MSGPENDING = 1           ' Operation succeeded with
  160.                      ' messages or non-fatal errors.
  161.       Const RMT_ERROR = 2                ' Operation failed; there will
  162.                      ' be at least one message in the
  163.                      ' Message table.
  164.       Const RMT_MSGTABLEERROR = 3        ' Connection to remote database
  165.                      ' failed because the Message
  166.                      ' table couldn't be created or
  167.                      ' because MSASP110.DLL was couldn't write
  168.                      ' to the specified Message table.
  169.       Const RMT_INVALIDHANDLE = 4        ' RMTQueryExecute or CloseRMTQuery
  170.                      ' functions were called with an
  171.                      ' invalid connection handle (invalid
  172.                      ' source field).
  173.       Const RMT_MESSAGEINSERTERROR = 5   ' Row couldn't be added to
  174.                      ' Messages table.
  175.  
  176.  
  177. RMTQueryDef Structure
  178. ---------------------
  179.    The information needed to connect to a back end and maintain the Message
  180.    tables is stored in a structure:
  181.  
  182.       Type RMTQueryDef
  183.      SQL As String            ' SQL statement to execute on back end.
  184.      ResultDB As String       ' Connection string to results database.
  185.      ResultTable As String    ' Base table name for resulting tables.
  186.      AppendResults As Integer ' Whether to append new result sets to
  187.                   ' existing tables.
  188.      MsgDB As String          ' Connection string to database for
  189.                   ' Message table.
  190.      MsgTable As String       ' Table name for Message table.
  191.      AppendMsgs As Integer    ' Whether to append new errors and
  192.                   ' messages to an existing Message table.
  193.      Source As Long           ' Handle to connection.
  194.      NumSets As Integer       ' Number of result sets returned and
  195.                   ' successfully written to a table from
  196.                   ' last RMTQueryExecute.
  197.       End Type
  198.  
  199.    Note   Except for Source (which is set in a call to CreateRMTQueryDef)
  200.       and NumSets (which is set by each call to RMTQueryExecute), you
  201.       set each of these values.
  202.  
  203. SQL            - SQL statement that will be passed to the SQL back end.
  204.          No syntax checking is performed; it is passed as-is to
  205.          the SQL back end. The SQL statement is sent when you call
  206.          RMTQueryExecute.
  207.  
  208. ResultDB       - Valid Microsoft Access database name that specifies the
  209.          database in which to store the result set; it is in
  210.          the form:
  211.  
  212.             databasename;UID=userid[;PWD=password]
  213.  
  214.          PWD is optional; however, omitting it in a secured
  215.          Microsoft Access database will cause an error.
  216.  
  217.          MSASP110.DLL opens the database at the time of the first call
  218.          to RMTQueryExecute.
  219.  
  220. ResultTable    - Name used to create Result tables returned from a remote
  221.          back end. These tables are created if there are result
  222.          sets returned as a result of the SQL statement passed in
  223.          the SQL argument. The first result table will be named
  224.          by the value contained in ResultTable, and subsequent
  225.          result sets returned from the same call will be named
  226.          by using this name as a base, and appending a different
  227.          number to it for each new table. For example, if
  228.          ResultTable has a value of "Example", and a call to
  229.          RMTQueryExecute yields three result sets, they will be
  230.          named Example, Example2, and Example3, respectively. If
  231.          tables already exist with the same name and the correct
  232.          structure, they will be used. The default is "RMTResults".
  233.  
  234.          If the value of AppendResults is False (0), the rows in
  235.          these tables will be purged before placing new data in
  236.          them. If the value of AppendResults is True (-1), the
  237.          data will be appended to the end of the appropriate
  238.          table. If tables exist with the same name and a
  239.          different structure, an error will be returned and table
  240.          creation will fail. If a result table contains two or
  241.          more identically-named columns, it is treated like any
  242.          multiple-result set.
  243.  
  244. AppendResults  - If False (0), the existing data in any results tables
  245.          will be purged when the table is used by RMTQueryExecute.
  246.          If True (-1), all results data will be appended to the
  247.          appropriate tables (see ResultTable, above). The default
  248.          is False.
  249.  
  250. MsgDB          - Same functionality as ResultDB, but used to specify
  251.          which database is to be used for the message table.
  252.  
  253. MsgTable       - Same functionality as ResultTable, but used to specify
  254.          the name of the Message table. This table remains open
  255.          until the connection is closed by the CloseRMTQueryDef
  256.          call. The default is "RMTErrLog".
  257.  
  258. AppendMsgs     - Same functionality as AppendResults, but used for the
  259.          Message table. The default is False.
  260.  
  261. Source         - Do not modify this argument except by calling the
  262.          CreateRMTQueryDef function.
  263.  
  264. NumSets        - Do not modify this argument except by calling the
  265.          RMTQueryExecute function. This argument specifies how
  266.          many result tables were created by the call.
  267.  
  268.  
  269. Function Syntax
  270. ---------------
  271.  
  272.    CreateRMTQueryDef
  273.    -----------------
  274.       Declare CreateRMTQueryDef Lib "MSASP110.DLL"
  275.           (ConnectString As String, QueryDefinition As RMTQueryDef)
  276.           As Integer
  277.  
  278.       ConnectString   - An ODBC connect string specifying the back end
  279.             that will execute the SQL statement. It is in
  280.             the form:
  281.  
  282.             DSN=datasourcename[;UID=userid];[PWD=password]
  283.  
  284.  
  285.       QueryDefinition - An RMTQueryDef variable. The following fields
  286.             are the only fields used by this function:
  287.  
  288.             MsgDB      - (Required) Specifies the database
  289.                      where the Message table will be
  290.                      created.
  291.  
  292.             MsgTable   - (Required) Specifies the name of the
  293.                      Message that will be created.
  294.  
  295.             AppendMsgs - (Optional) Specifies whether to
  296.                      append new errors or messages to
  297.                      an existing Message table. The
  298.                      default is False.
  299.  
  300.       Description
  301.       -----------
  302.       This function first attempts to create a Message table in the
  303.       database specified by the MsgDB field of the RMTQueryDef structure.
  304.       If this function cannot create the Message table, this function
  305.       returns RMT_MSG_TABLE_ERROR. This could occur for the following
  306.       reasons:
  307.  
  308.       o The table didn't already exist and couldn't be created.
  309.       o A table with the same name exists, but wasn't in the correct
  310.     message table format.
  311.       o MsgDB doesn't identify a valid database.
  312.  
  313.       If a table with the name specified by MsgTable already exists,
  314.       and is in the correct format, it will be used.  
  315.  
  316.       If the message table is successfully created, then the function
  317.       tries to establish the link specified by ConnectString. If this
  318.       succeeds, the function will fill in the Source field and return
  319.       either RMT_SUCCESS or RMT_MSGPENDING. If it fails, the reason for
  320.       the failure will be written into the Message table and the
  321.       function will return RMT_ERROR.
  322.  
  323.       Note   If the source field in the structure is non-zero and
  324.          contains a valid ODBC handle when this call is made,
  325.          the call will fail.
  326.  
  327.    RMTQueryExecute
  328.    ---------------
  329.       Declare RMTQueryExecute Lib "MSASP110.DLL"
  330.           (QueryDefinition As RMTQueryDef)
  331.           As Integer
  332.  
  333.       QueryDefinition - An RMTQueryDef variable. This must be a valid
  334.             RMTQueryDef variable that was included in a
  335.             previous call to CreateRMTQueryDef. The
  336.             following fields are the only ones used by
  337.             this function:
  338.  
  339.             Source        - (Required) Must have been
  340.                     filled in with a valid ODBC
  341.                     connection handle by a previous
  342.                     call to CreateRMTQueryDef.
  343.  
  344.             SQL           - (Required) The SQL statement
  345.                     to be executed by the back end.
  346.  
  347.             ResultDB      - (Optional) Name of the database
  348.                     for the result sets. Required
  349.                     only if the SQL statement
  350.                     returns rows.
  351.  
  352.             ResultTable   - (Required) Base name of result
  353.                     set tables.
  354.  
  355.             AppendResults - (Optional) Specifies whether to
  356.                     append new results to existing
  357.                     result tables. The default is
  358.                     False.
  359.  
  360.             AppendMsgs    - (Optional) Specifies whether to
  361.                     append new errors to an existing
  362.                     Message table. The default is
  363.                     False.
  364.  
  365.       Description
  366.       -----------
  367.       This function attempts to execute the SQL statement specified by
  368.       the SQL field on the back end specified by a previous call to
  369.       RMTCreateQueryDef. Result sets are written to tables named using
  370.       the ResultTable field with the naming scheme described above.
  371.  
  372.       Existing result tables are used if they are in the correct format.
  373.       New result sets will be appended to the end of existing tables if
  374.       AppendResults is True; otherwise, existing tables will be purged
  375.       before writing new results. Any errors will be reported in the
  376.       Message table specified by a previous call to CreateRMTQueryDef.
  377.       If the Message table is not accessible for some reason, this
  378.       function returns RMT_MSG_TABLE_ERROR. New errors will be appended
  379.       to the end of an existing Message table if AppendMsgs is True;
  380.       otherwise, the Message table will be purged with each call to
  381.       RMTQueryExecute. If the call succeeds and there are no messages or
  382.       errors, RMTQueryExecute returns RMT_SUCCESS. If the call succeeds,
  383.       but there are messages or errors (written to the Message table),
  384.       this function returns RMT_MSGPENDING. If the call fails, this
  385.       function returns RMT_ERROR.
  386.  
  387.  
  388.    CloseRMTQueryDef
  389.    ----------------
  390.       Declare CloseRMTQueryDef Lib "MSASP110.DLL"
  391.           (QueryDefinition As RMTQueryDef)
  392.           As Integer
  393.     
  394.       QueryDefinition - An RMTQueryDef variable. This must be a valid
  395.             RMTQueryDef variable that was included in a
  396.             previous call to CreateRMTQueryDef. The following
  397.             fields are the only ones used by this function:
  398.  
  399.             Source - (Required) ODBC connection handle
  400.                  specifying the connection to be closed.
  401.  
  402.       Description
  403.       -----------
  404.       This function closes an ODBC connection, all open Microsoft Access
  405.       tables used by the connection, and frees all memory associated with
  406.       the connection. It sets all values in the structure to zero (0) or
  407.       to empty strings. The Message table is the last thing to be closed.
  408.  
  409.       Any errors encountered during this call are written to the Message
  410.       table before it is closed. If errors are encountered, this function
  411.       returns RMT_ERROR. If messages are encountered during the closing
  412.       process, this function returns RMT_MSGPENDING. If MSASP110.DLL could not
  413.       close the Message table, this function returns RMT_MSG_TABLE_ERROR.
  414.       If no errors or messages are encountered, this function returns
  415.       RMT_SUCCESS.
  416.  
  417.    RMTError
  418.    --------
  419.       Declare RMTError Lib "MSASP110.DLL"
  420.           (QueryDefinition As RMTQueryDef, LastMessage As String)
  421.           As Integer
  422.  
  423.       QueryDefinition - An RMTQueryDef variable. This must be a valid
  424.             RMTQueryDef variable that was included in a
  425.             previous call to CreateRMTQueryDef. The following
  426.             fields are the only ones used by this function:
  427.  
  428.             Source - (Required) ODBC connection handle
  429.                  specifying the connection to be closed.
  430.  
  431.       LastMessage     - The text of the last message.
  432.  
  433.       Description
  434.       -----------
  435.       This function returns the text of the last error message(s) that
  436.       occurred. This ability to return error text is important when an
  437.       error message cannot be logged into the Message table due to some
  438.       failure (indicated by RMT_MSG_TABLE_ERROR).
  439.